package com.lego.bean;

import java.util.List;

public class PersonalOrdersVO<T>{
	private List<T> orders;//订单
	private int pageNum;//页号
	private int pageSize;//页大小
	private boolean hasPrev;//上一页
	private boolean hasNext;//下一页
	private int[] navigatorNums;//有效数组
	private String orderStatus;//订单状态，后台可以用select>option查看不同状态的订单
	private int totalPages;//总页数
	private int totalRows;//总条数
	public List<T> getOrders() {
		return orders;
	}
	public void setOrders(List<T> orders) {
		this.orders = orders;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public boolean isHasPrev() {
		return hasPrev;
	}
	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public int[] getNavigatorNums() {
		return navigatorNums;
	}
	public void setNavigatorNums(int[] navigatorNums) {
		this.navigatorNums = navigatorNums;
	}
	public String getOrderStatus() {
		return orderStatus;
	}
	public void setOrderStatus(String orderStatus) {
		this.orderStatus = orderStatus;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public PersonalOrdersVO(List<T> orders, int pageNum, int pageSize, String orderStatus, int totalRows) {
		super();
		this.orders = orders;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.orderStatus = orderStatus;
		this.totalRows = totalRows;
		
		if((totalRows%pageSize)!=0) {
			this.totalPages = (totalRows/pageSize)+1;
		}else {
			this.totalPages = totalRows/pageSize;
		}
		
		if(pageNum<=1) {
			this.hasPrev = false;
		}else {
			this.hasPrev = true;
		}
		
		if(pageNum>=totalPages) {
			this.hasNext = false;
		}else {
			this.hasNext = true;
		}
		
		if(totalPages<10) {
			this.navigatorNums = new int[totalPages];
		}else {
			this.navigatorNums = new int[10];
		}
		
		if(pageNum<=5) {
			for (int i = 0; i < navigatorNums.length; i++) {
				navigatorNums[i] = i+1;
			}
		}else if(pageNum>5&&pageNum+5<=totalPages) {
			for (int i = pageNum-4,k = 0; i <= pageNum+5; i++,k++) {
				navigatorNums[k] = i;
			}
		}else {
			for (int i = totalPages-navigatorNums.length+1,k = 0; i <= totalPages; i++,k++) {
				navigatorNums[k] = i;
			}
		}
	}
	public PersonalOrdersVO() {
		
	}
	
}
